package com.whnk.attendance.api.factory;

import com.whnk.attendance.api.RemoteMonthEmpStatisService;
import com.whnk.attendance.api.vo.MonthEmpStatisBatchQueryVo;
import com.whnk.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 每月统计(员工口径)服务降级处理
 *
 * @author
 */
@Component
public class RemoteMonthEmpStatisFallbackFactory implements FallbackFactory<RemoteMonthEmpStatisService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteMonthEmpStatisFallbackFactory.class);

    @Override
    public RemoteMonthEmpStatisService create(Throwable throwable) {
        log.error("每月统计(员工口径)服务调用失败:{}", throwable.getMessage());
        return new RemoteMonthEmpStatisService() {
            @Override
            public R<Boolean> batchComputer(MonthEmpStatisBatchQueryVo monthEmpStatisBatchQueryVo) {
                return R.fail("每月统计(员工口径)服务调用失败:" + throwable.getMessage());
            }
        };
    }
}
